#-*- coding: utf-8 -*-
from random import randrange
from pmcore.basecom import BaseComponent

class Server(BaseComponent):
    name = "Interaction Sample Server"
    # Сервер должен стартовать раньше
    weight = -1
    msglst = ["AAA","BBB","CCC"]
    # Сервер предоставляет сервис rnd-print
    def __init__(self):
        BaseComponent.__init__(self)
        self.provides = ({"name":"rnd-print","value":self.print_random, "version":"1.0"},)
      
    def print_random(self):
        print self.msglst[randrange(0,len(self.msglst))]

class Client(BaseComponent):
    name = "Interaction Sample Client"
    # Клиент требует сервис rnd-print
    requires = "rnd-print"
    
    def after_direct_import(self):
        func = get_service("rnd-print")
        func()
